package io.renren.wh.channel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.wh.channel.dao.ChannelConfigDao;
import io.renren.wh.channel.entity.ChannelConfigEntity;
import io.renren.wh.channel.service.ChannelConfigService;
import org.springframework.stereotype.Service;

import java.util.Map;



@Service("channelConfigService")
public class ChannelConfigServiceImpl extends ServiceImpl<ChannelConfigDao, ChannelConfigEntity> implements ChannelConfigService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ChannelConfigEntity> page = this.page(
                new Query<ChannelConfigEntity>().getPage(params),
                new QueryWrapper<ChannelConfigEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void updateByChannleId(ChannelConfigEntity channelConfig) {

        this.baseMapper.update(channelConfig,new UpdateWrapper<ChannelConfigEntity>()
                .eq("channelId",channelConfig.getChannelid()));
    }

    @Override
    public ChannelConfigEntity queryByChannleId(Integer channleId) {
        return super.getOne(new QueryWrapper<ChannelConfigEntity>().eq("channelId",channleId));
    }
}